﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace PMS.Logic.AutoComplete
{
    public partial class BasicData : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            String methodName = Request["method"];
            Type type = this.GetType();
            MethodInfo method = type.GetMethod(methodName);
            if (method == null) throw new Exception("method is null");
            try
            {
                method.Invoke(this, null);
            }
            catch
            {
                throw;
            }
        }

        //public void GetTaskCode()
        //{
        //    string q = Request.Form["q"];
        //    Object a = DALSession.Current.TM_TaskAssignDAL.GetListBy(m => m.TaskCode.Contains(q)).Select(m => new { value = m.TaskCode, text = m.TaskCode });
        //    Response.Write(JsonHelper.toJson(a));
        //}

        //public void GetTaskCodeByProjEng()
        //{

        //    string q = Request.Form["q"];
        //    string proj = Request.Form["proj"];
        //    string engName = Request.Form["engName"];
        //    Object a = DALSession.Current.TM_TaskAssignDAL.GetListBy(m => m.TaskCode.Contains(q) && m.ProjName.Contains(proj) && m.EngName.Contains(engName)).Select(m => new { value = m.TaskCode, text = m.TaskCode });
        //    Response.Write(JsonHelper.toJson(a));
        //}
        //public void GetEngNameByProj()
        //{
        //    string q = Request.Form["q"];
        //    string proj = Request.Form["proj"];
        //    Object a = DALSession.Current.TM_TaskAssignDAL.GetListBy(m => m.EngName.Contains(q) && m.ProjName.Contains(proj)).Select(m => new { value = m.EngName, text = m.EngName });
        //    Response.Write(JsonHelper.toJson(a));
        //}
        //public void GetProjName()
        //{
        //    string q = Request.Form["q"];
        //    Object a = DALSession.Current.BD_ProjInfoDAL.GetListBy(m => m.ProjName.Contains(q) || m.ProjNum.Contains(q)).Select(p => new { value = p.ProjName + "(" + p.ProjNum + ")", text = p.ProjName + "(" + p.ProjNum + ")" });
        //    Response.Write(JsonHelper.toJson(a));
        //}


        //获取非父权限
        public void GetSubPerm()
        {
            string q = Request.Form["q"];
            Object a = DALSession.Current.BD_PermissionDAL.GetListBy(m => m.Name.Contains(q) & m.IsFatherNode == "1").Select(p => new { value = p.Name, text = p.Name });
            Response.Write(JsonHelper.toJson(a));
            // Response.Write(JsonHelper.toJson(DALSession.Current.BD_PermissionDAL.GetListBy(p => p.IsFatherNode == "1").Select(p => new { value = p.Id, text = p.Name })));
        }
        //public void GetProjCode()
        //{
        //    string q = Request.Form["q"];
        //    Object a = DALSession.Current.BD_ProjInfoDAL.GetListBy(m => m.ProjNum.Contains(q)).Select(m => new { value = m.ProjNum, text = m.ProjNum });
        //    Response.Write(JsonHelper.toJson(a));
        //}

        //public void GetProjNameCode()
        //{
        //    string q = Request.Form["q"];
        //    if (q==null)
        //    {
        //        q = "";
        //    }
        //    Object a = DALSession.Current.BD_ProjInfoDAL.GetListBy(m => m.ProjName.Contains(q) || m.ProjNum.Contains(q)).Select(m => new { value = m.ProjNum , text = m.ProjName + "(" + m.ProjNum + ")" });
        //    Response.Write(JsonHelper.toJson(a));
        //}


        //public void GetEngName()
        //{
        //    string q = Request.Form["q"];
        //    if (q == null)
        //    {
        //        q = "";
        //    }
        //    Object a = DALSession.Current.BD_EngineerInfoDAL.GetListBy(m => m.EngName.Contains(q) || m.EngNum.Contains(q)).Select(e => new { value = e.EngName + "(" + e.EngNum + ")", text = e.EngName + "(" + e.EngNum + ")" });
        //    Response.Write(JsonHelper.toJson(a));
        //}

        //public void GetEngNameCode()
        //{
        //    string q = Request.Form["q"];
        //    Object a = DALSession.Current.BD_EngineerInfoDAL.GetListBy(m => m.EngName.Contains(q) || m.EngNum.Contains(q)).Select(m => new { value = m.EngNum , text = m.EngName + "(" + m.EngNum + ")" });
        //    Response.Write(JsonHelper.toJson(a));
        //}

        //public void GetEquipName()
        //{
        //    string q = Request.Form["q"];
        //    Object a = DALSession.Current.BD_EquipmentTotalDAL.GetListBy(m => m.EquipName.Contains(q)).Select(m => new { value = m.EquipName, text = m.EquipName });
        //    Response.Write(JsonHelper.toJson(a));
        //}
        //public void GetTaskIdCode()
        //{
        //    string q = Request.Form["q"];
        //    Object a = DALSession.Current.TM_TaskAssignDAL.GetListBy(m => m.TaskCode.Contains(q)).Select(m => new { value = m.ID, text = m.TaskCode });
        //    Response.Write(JsonHelper.toJson(a));
        //    //Response.Write(JsonHelper.toJson(DALSession.Current.TM_TaskAssignDAL.GetListBy(t => 1 == 1).Select(p => new { value = p.ID, text = p.TaskCode })));
        //}

        //获取储运部
        public void GetPcApplyName()
        {
            string q = Request.Form["q"];
            Object a = DALSession.Current.BD_UserInfoDAL.GetListBy(m => (m.UserName.Contains(q)) & m.UserState == "0" & m.DepId == 7).Select(p => new { value = p.UserName, text = p.UserName });
            Response.Write(JsonHelper.toJson(a));
        }
        //获取技术部
        public void GetPcApplyName1()
        {
            string q = Request.Form["q"];
            Object a = DALSession.Current.BD_UserInfoDAL.GetListBy(m => (m.UserName.Contains(q) ) & m.UserState == "0" & m.DepId == 3).Select(p => new { value = p.UserName, text = p.UserName });
            Response.Write(JsonHelper.toJson(a));
        }
        //获取采购部
        public void GetPcApplyName2()
         {
            string q = Request.Form["q"];
          //  BD_UserInfo b = new BD_UserInfo() {ID=0,UserName="全部" };
          //  List<BD_UserInfo> C = new List<BD_UserInfo>();
          //  C.Add(b);
          //  List<BD_UserInfo> D = DALSession.Current.BD_UserInfoDAL.GetListBy(m => (m.UserName.Contains(q) || m.NameCode == "q") & m.UserState == "0" & m.DepId == 6).ToList();
          //  C.AddRange(D);
          //object e=  C.Select(p => new { value = p.UserName, text = p.UserName });
            Object a = DALSession.Current.BD_UserInfoDAL.GetListBy(m => (m.UserName.Contains(q) ) & m.UserState == "0" & m.DepId == 6).Select(p => new { value = p.UserName, text = p.UserName });
            //Object b = new { value = "", text = "全部" };
            Response.Write(JsonHelper.toJson(a));
        }

        //获取质量部
        public void GetPcApplyName3()
        {
            string q = Request.Form["q"];
            Object a = DALSession.Current.BD_UserInfoDAL.GetListBy(m => (m.UserName.Contains(q)) & m.UserState == "0" & m.DepId == 5).Select(p => new { value = p.UserName, text = p.UserName });
            Response.Write(JsonHelper.toJson(a));
        }
        //获取生产部技术员
        public void GetPcApplyName4()
        {
            string q = Request.Form["q"];
            Object a = DALSession.Current.BD_UserInfoDAL.GetListBy(m => (m.UserName.Contains(q) ) & m.UserState == "0" & m.DepId == 4).Select(p => new { value = p.UserName, text = p.UserName });
            Response.Write(JsonHelper.toJson(a));
        }
        //获取采购部和外协
        public void GetPcApplyName5()
        {
            string q = Request.Form["q"];
            Object a = DALSession.Current.BD_UserInfoDAL.GetListBy(m => (m.UserName.Contains(q)) & m.UserState == "0" & (m.DepId == 6 || m.DepId == 4)).Select(p => new { value = p.UserName, text = p.UserName });
            Response.Write(JsonHelper.toJson(a));
        }
       
    }
}